package com.ep.demo.bo;

import java.util.UUID;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Repository;

import com.ep.demo.DBUtils;
import com.ep.demo.entity.Book;
import com.ep.entity.Paper;
@Repository("bookBO")
public class BookBO implements IBookBO{
	@Resource(name="sessionFactory")
	private SessionFactory sessionFactory;
	@Test
	public void saveBook(Book book){
//		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
//		Book book=new Book();
//		book.setId(UUID.randomUUID().toString());
//		book.setName("dddd");
//		book.setOldname("dddddffffff");
		this.getSession().save(book);
	}
	public Session getSession(){
		return this.sessionFactory.getCurrentSession();
	}
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	@Override
	public void savePaper(Paper paper) {
		this.getSession().save(paper);
	}
}
